<?php


class Tools extends MY_Controller
{

    public function message($to = 'World')
    {
        echo "Hello {$to}!" . PHP_EOL;
    }


    /**
     * $type :推送类型 1京东  2 拼多多
     * 推送任务至任务池中
     */
    public function sendtask($type = 1)
    {
        set_time_limit(0);
        $this->load->model('Jd_task_jd_model');
        $row = $this->Jd_task_jd_model->getwaittask();
        if (empty($row)) {
            $msg['code'] = 1;
            $msg['msg'] = "没有待推送的任务";
            echo "没有待推送的任务";
            exit;
            $this->sendjsonmsg($msg);
        }
        $this->load->model('Jd_task_jd_list_model');
        $this->load->model('Jd_task_jd_list_pool_model');
        $allid = 0;
        foreach ($row as $key => $value) {
            $taskid = $value['id'];
            $interval = $value['interval'];
            $lastsendtime = $value['lastsendtime'] ? $value['lastsendtime'] : 0;
            $realinterval = intval(time() - $lastsendtime) / 60;
            if ($realinterval < $interval) {
                continue;
            }
            $listrow = $this->Jd_task_jd_list_model->getminlitstake($taskid);
            if (empty($listrow)) {
                continue;
            }


            $listrow['listid'] = $listrow['id'];
            $listrow['addtime'] = time();
            unset($listrow['id']);
            unset($listrow['hunter_id']);
            unset($listrow['hunter_name']);
            //unset($listrow['team']);
            $listrow['team'] = $value['team'];
            unset($listrow['update']);
            $type = $value['type'];
            $listrow['shop_name'] = $value['shop_name'];

            $this->db->trans_begin();
            $result = $this->sendtopools($taskid, $listrow);
            if ($result) {
                $allid++;
                $this->db->trans_commit();
                $redis = $this->MyRedis();
                $redis->update('poolnub' . $type, 1);
            } else {
                $this->db->trans_rollback();
                continue;
            }
        }
        if (!$allid) {
            $msg['code'] = 1;
            $msg['msg'] = "没有合适任务或推送失败";
            echo "没有合适任务或推送失败";
            exit;
            $this->sendjsonmsg($msg);
        }
        $this->Resetpoolsnumber();
        echo "成功推送" . $allid . "条子任务";
        exit;
    }


    /**
     * 更新入任务池
     */
    public function sendtopools($taskid, $listrow)
    {


        $r = $this->Jd_task_jd_list_pool_model->addtasklisttopoll($listrow); //插入任务池中
        if (!$r) {
            return false;
        }
        $idlist = $listrow['listid'];
        $result = $this->Jd_task_jd_list_model->updatapool($idlist);//更新列表状态
        if (!$result) {
            return false;
        }
        $result = $this->Jd_task_jd_model->UpdatelastSendTime($taskid);//更新列表状态
        if (!$result) {
            return false;
        }
        return true;
    }

    /**
     *
     * 计算商户所有余额状态
     */
    public function totalbusiness()
    {

        $now = time();
        $yestodaydate = date("Y-m-d", strtotime("-1 day"));
        $yestoday = strtotime($yestodaydate); //昨天凌晨
        $this->load->model('Jd_task_jd_list_model');
        $row = $this->Jd_task_jd_list_model->totalbunissmoney($yestoday);
        $this->load->model('Jd_buniess_balance_model');

        $this->Jd_buniess_balance_model->addlog($row, $yestodaydate);


        $this->Flataccount();
        $this->load->model('Jd_task_jd_list_pool_model');
        $this->Jd_task_jd_list_pool_model->truncatelog();
        echo "完成";
    }

    public function Resetpoolsnumber()
    {
        $this->load->model('Jd_task_jd_list_pool_model');
        $result = $this->Jd_task_jd_list_pool_model->getpoolsnumber();
        $redis = $this->MyRedis();

        $arr[1] = 1;
        $arr[2] = 2;
        foreach ($result as $id => $v) {
            $redis->set('poolnub' . $v['type'], $v['num']);
            unset($arr[$v['type']]);
        }
        if (!empty($arr)) {
            foreach ($arr as $id => $v) {
                $redis->set('poolnub' . $id, 0);
            }
        }
        echo $redis->get('poolnub1') . "__" . $redis->get('poolnub2');
        exit;
    }

    /**
     * 发送充值审核提醒
     */
    public function sendrechargemsg()
    {
        $date1 = date('H');
        if ($date1 < 9 || $date1 > 20) {
            return;
        }
        $this->load->model('Jd_pay_model');
        $where = "where  p1.`status`=0  ";
        $_order = 'order by p1.id desc';
        $_select = "p1.id";
        $sql = "select SELECT from `jd_pay` as p1                 
                             			   SQL   ORDER LIMIT";
        $_data = array("sql" => $sql,
            "_sql" => $where,
            "_select" => $_select,
            "_order" => $_order,
            "limit" => "",
            "page" => 1,
            "epage" => 10000);

        $this->load->model('Jd_pay_model');
        $result = $this->Jd_pay_model->get_server_list($_data);


        if (empty($result['list'])) {
            return;
        }
        $this->send(15212414880, 'cjtx');
    }

    public function send($phone, $code)
    {
        $result = $this->sendSms($phone, $code);
        if (@$result['code'] == 'OK' || @$result['Code'] == 'OK') {
            echo "发送成功";
            exit;
        }
        echo "发送失败";
    }


    public function Flataccount()
    {
        $date = date('Y-m-d', time() - 24 * 3600);
        $this->load->model('Jd_buniess_balance_model');
        $list = $this->Jd_buniess_balance_model->getlist($date);
        foreach ($list as $id => $v) {
            $row['money'] = $v['balance'];
            $row['webid'] = $v['webid'];
            $row['gold'] = $v['balancegold'];
            $row['user_id'] = $v['user_id'];
            $row['remarks'] = "任务余额归帐";
            $this->moneyupdate($row, 6);
        }
    }

    public function fanli()
    {
        $this->load->model('Jd_task_jd_model');
        $this->load->model('Jd_pay_log_model');
        $list = $this->Jd_task_jd_model->monthsend();
        $fanli = $this->getconfig("VIPfanli");
        foreach ($list as $id => $v) {
            if ($v['number'] >= $fanli['num']) {
                $row['user_id'] = $v['business_id'];
                $row['money'] = $fanli['money'];
                $row['gold'] = 0;
                $row['remarks'] = "VIP每月奖励";
                $result = $this->Jd_pay_log_model->checkFuli($v['business_id']);
                if (empty($result)) {
                    $r = $this->moneyupdate($row, 6, $this->user_id);
                }
            }
        }
    }


    public function getallinfo()
    {
        $this->load->model('Jd_pay_log_model');
        $this->load->model('Jd_task_jd_list_model');
        $this->load->model('Jd_users_model');
        $this->load->model('Jd_day_count_model');
        $TODAY = date('Y-m-d   05:30:00', time() - 24 * 3600);
        $TODAY2 = date('Y-m-d  05:30:00');
        $_POST['date1'] = $TODAY;
        $_POST['date2'] = $TODAY2;
        $sql = "select * from jd_weblist where addtime>0 ";

        $list = $this->Jd_pay_log_model->getbysql($sql);

        foreach ($list as $id => $v) {
            $this->session->web_id = $v['id'];
            $this->web_id = $v['id'];
            $payday = $this->Jd_pay_log_model->getallmoney(1, "", $v['id']);
            $taskmoney = $this->Jd_pay_log_model->getallmoney(2, "", $v['id']);
            $back = $this->Jd_pay_log_model->getallmoney(6, '任务余额归帐', $v['id']);
            $task = $this->Jd_task_jd_list_model->getdatebydate($TODAY, $TODAY2, $v['id']);
            $blance = $this->Jd_users_model->getdatebydate($v['id']);
            $row = array();
            $row['date'] = date('Y-m-d', time() - 24 * 3600);
            $row['addtime'] = time();
            $reg = $this->Jd_users_model->getreg($TODAY, $TODAY2, $v['id']);
            $row['regnum'] = $reg['regnum'] ? $reg['regnum'] : 0;
            $row['pay'] = $payday['allmoney'] ? $payday['allmoney'] : 0;
            $row['pay_user'] = $payday['num'] ? $payday['num'] : 0;
            $row['task_money'] = $taskmoney['allmoney'] ? -$taskmoney['allmoney'] : 0;
            $row['task_gold'] = $taskmoney['allgold'] ? -$taskmoney['allgold'] : 0;
            $row['back_money'] = $back['allmoney'] ? $back['allmoney'] : 0;

            $row['task_num'] = $task['all'] ? $task['all'] : 0;
            $row['balance'] = $blance['money'] ? $blance['money'] : 0;
            $row['balance_gold'] = $blance['gold'] ? $blance['gold'] : 0;
            $row['webid'] = $v['id'];

            $this->Jd_day_count_model->addlog($row, $v['id']);
        }
        parent::getwebid();
    }


    function setexcelview()
    {
        $this->load->view('tools/excel');
    }

    function setexcel()
    {


        $str = $this->input->post('excel');
        $str = trim($str);
        $str = str_replace('金融企业应在每批次不良资产转让工作结束后（ ）个工作日内，向同级财政部门和<span style=\"white-space:normal;\">中国银保监会<\/span>或属地银监局报告转让方案及处置结果。<br \/>', 'XXXXXXXX', $str);
        $str = str_replace('金融企业应在每批次不良资产转让工作结束后(即金融企业向受让资产管理公司完成档案移交)30个工作日内，向同级财政部门和<span style=\"white-space:normal;\">中国银保监会<\/span>或属地银监局报告转让方案及处置结果，其中中央管理的金融企业报告财政部和<span style=\"white-space:normal;\">中国银保监会<\/span>，地方管理的金融企业报告同级财政部门和属地银监局。同一报价日发生的批量转让行为作为一个批次。', 'yyyyyyy', $str);
        $str = str_replace('下列不良资产不得进行批量转让：①债务人或担保人为国家机关的资产；②经\国务院批准列入全国企业政策性关闭破产计划的资产；③国防军工等涉及国家安全和敏感信息的资产；④个人贷款；⑤在借款合同或担保合同中有限制转让条款的资产；⑥国家法律法规限制转让的其他资产。', 'ZZZZZZ', $str);

        $str = json_decode($str, true);


        if (isset($str['list'])) {
            $this->setexcel233($this->input->post('excel'));
            exit;
        }
        $name = $str['data']['name'];
        $row = array();
        $row = $str['data']['qGroup'];
        $row2 = array();

        foreach ($row as $id => $qGroup) {
            foreach ($qGroup['qList'] as $qid => $v) {
                $newvalue = array();

                $newvalue['typeName'] = $v['typeName'];
                $v['title'] = str_replace('<br/>', "", $v['title']);
                $v['title'] = str_replace("\r\n", "", $v['title']);
                $newvalue['title'] = $v['title'];
                $v['answerAnalysis'] = str_replace('<br/>', "", $v['answerAnalysis']);
                $v['answerAnalysis'] = str_replace("\r\n", "", $v['answerAnalysis']);

                $v['answerAnalysis'] = strip_tags($v['answerAnalysis']);


                $newvalue['answerAnalysis'] = $v['answerAnalysis'];


                $newvalue['answer'] = $v['answer'];
                $options = array();
                if (isset($v['options'])) {
                    foreach ($v['options'] as $id2 => $v2) {
                        $v2['b'] = str_replace('<br/>', "", $v2['b']);
                        $v2['b'] = str_replace("\r\n", "", $v2['b']);
                        if ($v['typeName'] != "判断题") {
                            switch ($id2) {
                                case 0:
                                    $v2['b'] = "A." . $v2['b'];
                                    break;
                                case 1:
                                    $v2['b'] = "B." . $v2['b'];
                                    break;
                                case 2:
                                    $v2['b'] = "C." . $v2['b'];
                                    break;
                                case 3:
                                    $v2['b'] = "D." . $v2['b'];
                                    break;
                                case 4:
                                    $v2['b'] = "E." . $v2['b'];
                                    break;
                            }
                        }
                        $options[] = $v2['b'];
                    }
                }

                $options = implode($options);
                $newvalue['options'] = $options;
                $row2[] = $newvalue;
            }
        }
        unset($str);
        unset($row);

        $str = array();
        $str[] = '类型';
        $str[] = '题目';
        $str[] = '解析';
        $str[] = '答案';
        $str[] = '选择';
        $this->excel_out2($str, $row2, $name);
    }

    function setexcel233($str = "")
    {
        if (!$str) {
            $str = $this->input->post('excel');
        }
        $str = json_decode($str, true);
        $name = "自动生成标题" . time();
        $row = array();
        if (isset($str['list']['examDtoList'])) {
            $row = $str['list']['examDtoList'];
        } else {
            $row = $str['list'];
        }
        $row2 = array();
        foreach ($row as $qid => $v) {
            $newvalue = array();
            $newvalue['examTypeName'] = $v['examTypeName'];
            $v['content'] = str_replace('<br />', "\r\n", $v['content']);
            $v['content'] = strip_tags($v['content']);

            $newvalue['content'] = $v['content'];

            $v['analysis'] = str_replace('<br />', "\r\n", $v['analysis']);
            $v['analysis'] = strip_tags($v['analysis']);

            $newvalue['analysis'] = $v['analysis'];
            $newvalue['answer'] = $v['answer'];
            if ($v['examTypeName'] == "判断题") {
                $newvalue['answer'] = $v['answer'] ? "正确" : "错误";
            }

            $options = array();
            foreach ($v['optionList'] as $id2 => $v2) {
                switch ($id2) {
                    case 0:
                        $v2 = " A. " . $v2 . "\r\n";
                        break;
                    case 1:
                        $v2 = " B. " . $v2 . "\r\n";
                        break;
                    case 2:
                        $v2 = " C. " . $v2 . "\r\n";
                        break;
                    case 3:
                        $v2 = " D. " . $v2 . "\r\n";
                        break;
                    case 4:
                        $v2 = " E. " . $v2 . "\r\n";
                        break;
                }

                $options[] = $v2;
            }
            $options = implode($options);
            $newvalue['options'] = $options;


            $row2[] = $newvalue;


        }


        unset($str);
        unset($row);


        $str = array();
        $str[] = '类型';
        $str[] = '题目';
        $str[] = '解析';
        $str[] = '答案';
        $str[] = '选择';
        $this->excel_out2($str, $row2, $name);
    }


    /**
     * 发送定时任务
     */
    function sendtimetask()
    {
        set_time_limit(0);
        $this->load->model('Jd_task_jd_model');
        $row = $this->Jd_task_jd_model->gettimetask();


        if (empty($row)) {
            echo "没有需要发布的定时任务";
            exit;
        }

        foreach ($row as $id => $v) {
            $r = $this->SendPddTask($v);
            if (!empty($r)) {
                echo $r . "-" . $v['id'] . "<br>";
            }

        }
    }

    /**
     * 发布拼多多任务
     * @param array $row
     */
    public function SendPddTask($row = array())
    {
        if (empty($row)) {
            $row = $this->input->post();
        }
        $this->user_id = $row['business_id'];
        $this->userinfo = $this->getcuserinfo(1, $row['business_id']);
        if ($this->userinfo['VIP']) {
            $this->is_vip = 1;
        }
        $type_h = $row['type_h'];
        $allmoney = $row['pay_price'] * $row['each_single'];
        $allgold = $row['gold'];
        if ($row['type_h'] == 1 && $this->is_vip) {//会员福利
            $goldnum = $this->getconfig("VIPfuli");
            $goldnum = $goldnum['goldnum'];
        } else {
            $goldnum = 0;
        }
        $allgold = $allgold - $goldnum;
        $allmoney = $allmoney * $row['number'];
        $result = $this->checkmoney($allmoney, $allgold);

        if (!$result) {
            return "金币或者余额不足";
        }

        $this->db->trans_begin();
        $array = array();
        $array['taskid'] = $row['id'];
        $array['list'] = $row['number'];
        $array['price'] = $row['pay_price'];
        $array['goods_name'] = $row['goods_name'];
        $array['shop_name'] = $row['shop_name'];
        $array['number'] = $row['each_single'];
        $array['link'] = $row['link'];
        $array['pay_type'] = $row['pay_type'];
        $array['single_price'] = $row['single_price'];
        $array['group_price'] = $row['group_price'];
        $array['remarks'] = $row['remarks'];
        $array['keyword'] = $row['keyword'];
        $array['sku'] = $row['sku'];
        $array['type'] = 2;
        $array['endtime'] =  $row['endtime'];
        $array['type_h'] = $row['type_h'];
        $array['webid'] = $row['webid'];
        $array['daifa'] = $row['daifa'];
        $array['gold'] = round($allgold / $row['number'], 2);
        if ($row['type_h'] == 1) {
            $array['chat'] = $row['chat'];
            $array['compare'] = $row['compare'];
            $array['collection'] = $row['collection'];
            $array['sign'] = $row['sign'];
            $array['overnight'] = $row['overnight'];
            $array['sex'] = $row['sex'];
            $array['dianzan'] = $row['dianzan'];
            $array['night'] = $row['night'];
        }
        if ($row['type_h'] == 2) {
            $array['showpic'] = $row['showpic'];
        }
        if (isset($row['picurl'])) {
            $array['picurl'] = isset($row['picurl']) ? $row['picurl'] : "";
        }
        $this->load->model('Jd_task_jd_list_model');

        $has = $this->Jd_task_jd_list_model->checktsak($row['id']);
        if ($has) {
            return "已发布";
        }
        $this->load->model('Jd_task_jd_list_model');
        $this->load->model('Jd_pic_model');
        $taskid = $array['taskid'];
        $picresult = $this->db->select("id")->from('pic')->where("`taskid`=$taskid")->get()->result_array();
        $piclist = array();
        foreach ($picresult as $id => $v) {
            $piclist[] = $v['id'];
        }

        $testresult = $this->db->select("id")->from('jd_text')->where("`taskid`=$taskid")->get()->result_array();
        $testlist = array();
        foreach ($testresult as $id => $v) {
            $testlist[] = $v['id'];
        }
        $result2 = $this->Jd_task_jd_list_model->addtasklist($array, $this->user_id, $piclist, $testlist);

        if ($result2) {//如果任务发布成功即开始
            $newrow['task_nub'] = $row['number'];
            $newrow['allgold'] = abs($allmoney);
            $newrow['allmoney'] = abs($allgold);
            $this->UpdataUserinfo($newrow, $this->user_id);

            $orderlit = $this->Jd_task_jd_list_model->getlistidbytask(array($taskid));
            $result = false;
            foreach ($orderlit as $key => $value) {
                $newrow = array();
                $newrow['money'] = round($row['pay_price'] * $row['each_single'], 2);
                $newrow['gold'] = round($row['gold'] / $row['number'], 2);
                $newrow["user_id"] = $this->user_id;
                $result = $this->moneyupdate($newrow, 2, $value['id']);
            }
            /* $newrow = array();
             $newrow['money'] = $allmoney;
             $newrow['gold'] = $allgold;
             $newrow["user_id"] = $this->user_id;
             $result = $this->moneyupdate($newrow, 2, $row['id']);*/
            if ($result) {
                $new["user_id"] = $this->user_id;
                $new['frozenmoney'] = -abs($allmoney);
                $new['frozengold'] = -abs($allgold);
                $result = $this->frozenmoney($new);
            }

        } else {
            $this->db->trans_rollback();
            $msg['code'] = 1;
            $msg['msg'] = '子任务发布失败';
            return "子任务发布失败";
            return;
        }
        if (!$result) {
            $this->db->trans_rollback();
            $msg['code'] = 1;
            $msg['msg'] = '任务信息日志更新失败';
            return "任务信息日志更新失败";
            return;
        }

        $this->checkvip();
        $this->checkInvitation();

        $this->load->model('Jd_task_jd_model');
        $this->Jd_task_jd_model->updaetime($row['id']);
        $this->db->trans_commit();
        echo "完成" . $row['id'] . "<br>";
        return "";
    }

    /**
     *  检测当前用户的邀请人或者自己是否可以升级为VIP
     */
    public function checkvip()
    {
        return;
        $this->load->model('Jd_users_model');
        $result = $this->Jd_users_model->GetUserById($this->user_id);
        if ($result['recommender_id']) {//检测其邀请人
            $num = $this->Jd_users_model->tuijiansend($result['recommender_id']);
            if ($num) {
                $this->Jd_users_model->addvip($result['recommender_id']);
            }
        }
        if ($this->is_vip) {
            return;
        }
        $this->load->model('jd_user_total_model');
        $update = $this->jd_user_total_model->getonebyuserid($this->user_id, 'task_nub');
        if (!empty($update[0]) && $update[0]['task_nub'] >= 500) {
            $this->Jd_users_model->addvip($this->user_id);
        }
    }


    public function checkInvitation()
    {
        return;
        if (!$this->userinfo['recommender_id']) {
            return;
        }
        $this->load->model('jd_user_total_model');
        $update = $this->jd_user_total_model->getonebyuserid($this->user_id, 'task_nub');
        if (!empty($update[0]) && $update[0]['task_nub'] == 1) {
            $newrow = array();
            $newrow['user_id'] = $this->userinfo['recommender_id'];
            $newrow['gold'] = 10;
            $this->moneyupdate($newrow, 3, $this->user_id);
        }
    }


    public function dorepaer()
    {
        $sql = "SELECT  p1.id,p1.webid , p2.webid as 'webid2' from    jd_task_jd_list as p1
left join  jd_users as p2 on p1.business_id=p2.id
WHERE p1.webid!=p2.webid";
        $this->load->model('jd_user_total_model');
        $update = $this->jd_user_total_model->getonebyuserid($this->user_id, 'task_nub');

    }


    public function setWebMonth()
    {
        $page = $this->input->post('page');

        $_sql = "where 1=1";
        $_select = " p1.*";
        $_order = " order by p1.id desc ";

        $sql = "select SELECT from `jd_weblist` as p1                        
                             			   SQL   ORDER LIMIT";
        $_data = array("sql" => $sql,
            "_sql" => $_sql,
            "_select" => $_select,
            "_order" => $_order,
            "limit" => "",
            "page" => $page,
            "epage" => 100);

        $this->load->model('Jd_users_model');
        $this->load->model('Jd_pay_log_model');
        $this->load->model('Jd_task_jd_list_model');

        $this->load->model('Jd_web_month_model');
        $_POST['webid'] = "全部";//搜全部站点
        $result = $this->Jd_users_model->get_server_list($_data);

        $start = date('Y-m-01 00:00:00', strtotime('-1 month'));;
        $end = date('Y-m-t 23:59:59', strtotime('-1 month'));

        foreach ($result['list'] as $id => $v) {
            $param['webid'] = $v['id'];
            $nowrow = $this->Jd_task_jd_list_model->getweekdata($start, $end, $param);
            $sendnum = $this->Jd_task_jd_list_model->getSendNumber($start, $end, $param);

            $v['sendnum'] = intval($sendnum['sendnum']);
            $v['not'] = 0;
            $v['finlish'] = 0;
            $v['profit'] = 0;
            $v['real_price'] = 0;
            $v['gold'] = 0;
            $v['cost'] = 0;
            $v['profit'] = 0;
            $v['cost'] = 0;
            $v['cost3'] = 0;

            foreach ($nowrow as $id2 => $v2) {
                if (isset($v2['all'])) {
                    $v2['all'] = intval($v2['all']);
                } else {
                    $v2['all'] = 0;
                }
                if ($v2['status'] == 0) {
                    $v['not'] += $v2['all'];
                }
                if ($v2['status'] == 1) {
                    $v['not'] += $v2['all'];
                }
                if ($v2['status'] == 2) {
                    $v['cost'] = $v2['cost'];
                    $v['cost3'] = $v2['cost3'];
                    $v['real_price'] = $v2['real_price'];
                    $v['gold'] = $v2['gold'];
                    $v['finlish'] = $v2['all'];
                    $v['profit'] = $v2['all'] ? round(($v2['gold'] - $v2['cost']) * 0.9, 2) : 0;
                    $v['profit'] = round($v['profit'] - $v2['cost3'], 2);
                }
            }
            $reg = $this->Jd_users_model->getreg($start, $end, $v['id']);
            $payday = $this->Jd_pay_log_model->getallmoney(1, "", $v['id'], $start, $end);
            $v['regnum'] = intval($reg['regnum']);
            $v['pay'] = $payday['allmoney'] ? $payday['allmoney'] : 0;
            $logrow = array();
            $logrow['webid'] = $v['id'];
            $logrow['date'] = date("Y-m-1", time() + 24 * 3600 * 4);
            $logrow['addtime'] = time();
            $logrow['pay'] = $v['pay'];
            $logrow['pay_user'] = $payday['num'] ? $payday['num'] : 0;
            $logrow['task_num'] = $v['finlish'];
            $logrow['sendnum'] = $v['sendnum'];
            $logrow['regnum'] = $v['regnum'];
            $logrow['task_money'] = isset($v['real_price']) ? $v['real_price'] : 0;
            $logrow['task_gold'] = isset($v['gold']) ? $v['gold'] : 0;
            $logrow['cost'] = round($v['cost'] * 0.9, 2) + $v['cost3'];
            $logrow['profit'] = $v['profit'];
            $this->Jd_web_month_model->addlog($logrow, $v['id']);
        }
        //var_dump($result); exit;
        $this->sendjsonmsg($result);
    }

}
